package com.onesports.intelligent.k12.polarlight.mapper.student;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.onesports.intelligent.k12.polarlight.annotation.DataPermission;
import com.onesports.intelligent.k12.polarlight.domain.dto.student.AttendanceQueryDTO;
import com.onesports.intelligent.k12.polarlight.domain.entity.student.StudentAttendance;
import com.onesports.intelligent.k12.polarlight.domain.vo.attendance.ScheduleDetailVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.student.ClassRecordVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.student.StudentAttendanceVO;
import com.onesports.intelligent.k12.polarlight.enums.DataPermissionTypeEnum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;

import java.util.Date;
import java.util.List;

/**
 * 考勤记录
 *
 * @author
 * @since 1.0.0 2022-07-08
 */
@Mapper
public interface StudentAttendanceMapper extends BaseMapper<StudentAttendance> {


    List<StudentAttendanceVO> stuAttendanceInfo(@Param("detailIds") List<String> detailIds, @Param("studentIds") List<String> studentIds);

    /**
     * 分页
     *
     * @param dto  入参
     * @param page 分页参数
     * @return IPage<ScheduleDetailVO>
     */
    @DataPermission(alias = "ci")
    IPage<ScheduleDetailVO> attendancePage(@Param("page") Page<ScheduleDetailVO> page, @Param("dto") AttendanceQueryDTO dto);

    /**
     * 考勤学员详情
     *
     * @param scheduleDetailId 课表详情id
     * @param page             分页参数
     * @return List<StudentAttendanceVO>
     */
    IPage<StudentAttendanceVO> detail(Page<StudentAttendanceVO> page, @Param("scheduleDetailId") String scheduleDetailId, @Param("classId") String classId);


    /**
     * 上课记录
     *
     * @param classStudentIds 班级学员ids
     * @return List<ClassRecordVO>
     */
    @DataPermission(alias = "csd")
    List<ClassRecordVO> classRecordList(@Param("classStudentIds") List<String> classStudentIds,
                                        @Param("campusIds") List<String> campusIds,
                                        @Param("classStatus") List<String> classStatus);


    /**
     * 获取考勤信息
     *
     * @param classStudentId         班级学生Id
     * @param courseScheduleDetailId 课表时段明细表Id
     * @return {@link StudentAttendance}
     */
    StudentAttendance findStudentAttendance(@Param("classStudentId") String classStudentId, @Param("courseScheduleDetailId") String courseScheduleDetailId);

    /**
     * 更新考勤信息
     *
     * @param classStudentId         班级学生Id
     * @param courseScheduleDetailId 课表时段明细表Id
     */
    void updateStudentAttendance(@Param("classStudentId") String classStudentId, @Param("courseScheduleDetailId") String courseScheduleDetailId);

    /**
     * 获取今日已考勤信息
     *
     * @param scheduleDetailIds 课表详情ids
     * @param currentDate       当前日期
     * @param attendanceStatus  考勤状态
     * @return List<StudentAttendance>
     */
    List<StudentAttendance> attendanceInfo(@Param("scheduleDetailIds") List<String> scheduleDetailIds,
                                           @Param("currentDate") Date currentDate,
                                           @Param("attendanceStatus") String attendanceStatus);
}
